﻿var cloudninja = cloudninja || {};
cloudninja.metering = cloudninja.metering || {};
cloudninja.metering.util = cloudninja.metering.util || {};


cloudninja.metering.util.Util = {
    // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference:Global_Objects:Date#Example:_ISO_8601_formatted_dates
    
    dateToIso8601String: function(date) {
        function pad(n) { return n < 10 ? '0' + n : n; }
        
        return date.getUTCFullYear() + '-'
            + pad(date.getUTCMonth() + 1) + '-'
            + pad(date.getUTCDate()) + 'T'
            + pad(date.getUTCHours()) + ':'
            + pad(date.getUTCMinutes()) + ':'
            + pad(date.getUTCSeconds()) + 'Z';
    }
};
